package cc.idoone.joddhttp.demo;

import jodd.http.HttpRequest;
import jodd.http.HttpResponse;

import java.net.SocketException;

/**
 * @author hemj
 * @version 2017/7/31
 */
public class KeepAliveRequestDemo {
    private static final String URL = "http://localhost:8088/joddhttp/test";

    public static void main(String[] args) throws SocketException {
        // keep-alive
        HttpRequest request = HttpRequest.get(URL);
        HttpResponse response = request.connectionKeepAlive(true).send();
        System.out.println(response.charset("UTF-8").bodyText());
        // next request
        request = HttpRequest.get(URL + "?udi=1");
        response = request.keepAlive(response, true).send();
        System.out.println(response.charset("UTF-8").bodyText());
        // last request
        request = HttpRequest.get(URL + "?uname=1");
        response = request.keepAlive(response, false).send();
        System.out.println(response.charset("UTF-8").bodyText());
    }

}
